function tech_search(){
	if($('.technology-search').css('display')=='none') $('.technology-search').show();
	else $('.technology-search').hide();
}

var myModule = angular.module('myModule', []);



myModule.controller('MyController', function ($scope, $http,$location) {
    
    $scope.contest=[];
    $scope.countList=[];
    $scope.teamList=[];
    
    $scope.currentPageitems = [];
    $scope.currentPage = 1;
    $scope.pages = [];
    $scope.pagePrev = 0;
    $scope.pageNext = 0;
    $scope.pageSize = 1;
    
    /*$scope.gotoPage = function(page) {
        $scope.currentPage = page;
    	var pageCount= Math.ceil($scope.countList.length * 1.0 / $scope.pageSize);
    	var pageBase = Math.floor(($scope.currentPage - 1) / 10) * 10;
    	$scope.pages = [];
        for (var i = 1; i <= 10 && pageBase + i <= pageCount; ++i)
            $scope.pages.push(pageBase + i);
        if (pageBase > 0) $scope.pagePrev = pageBase; else delete $scope.pagePrev;
        if (pageBase + 11 < pageCount) $scope.pageNext = pageBase + 11; else delete $scope.pageNext;

    	$scope.currentPageitems = [];
    	for (var i = 0; i < $scope.pageSize; ++i) {
    		var n = ($scope.currentPage - 1) * $scope.pageSize + i;
    		if (n >= $scope.countList.length) break;
    		$scope.currentPageitems.push($scope.countList[n]);    		
    	}
    } 
    */
    
    
    $scope.loadData = function() {
        myUtil.onHttp($http, 'get', 'contestAll.do', null, null, 
        		function(data){
        			$scope.contest=data;
        			$scope.contest_id=$scope.contest[0].contest_id;
        			
        			myUtil.onHttp($http,'get','contest_reg2.do',{id:$scope.contest_id},null,
        		    		function(data){
        		    			$scope.countList=data;
        		    			$scope.count=$scope.countList[$scope.countList.length-1];
        		    			$scope.teamSearch();
  
        		    		
        		    });
        			
        		}
        );
        
        
    }
    
    $scope.change=function(){
    	myUtil.onHttp($http,'get','contest_reg2.do',{id:$scope.contest_id},null,
    		function(data){
    			$scope.countList=data;
    			if(($scope.countList==0)){
    				$scope.error=true;
    				$scope.teamList=[];
    			}
    			else{
    				$scope.error=false;
    			$scope.count=$scope.countList[$scope.countList.length-1];
    			$scope.teamSearch();
    			}
    		
    	});
    }
    
    
    
    $scope.teamSearch=function(){
    	myUtil.onHttp($http,'get','teamSearch.do',{contest_reg_id : $scope.count.contest_reg_id},null,
    			function(data){
    				$scope.teamList=data;
    	})
    }
    
    

   
    
   

    $scope.loadData();        
});